<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js"></script>
</head>
<body>
    <button>发请求</button>
    <button>发post</button>
    <script>
        const btn = document.querySelectorAll('button')
        btn[0].onclick = function(){
            axios({
                method: 'GET',
                url: 'http://hmajax.itheima.net/api/area?pname=天津&cname=天津市',
            }).then(response => {
                console.log(response);
            })
        }

        btn[1].onclick = function(){
            axios({
                method: 'POST',
                url: 'http://hmajax.itheima.net/api/register',
                data:{
                    username:'lkjhgf1234',
                    password:'123456768'
                }
            }).then(response => {
                console.log(response);
            })
        }
    </script>
</body>
</html>